<template>
  <a-drawer
    :title="title"
    :width="width"
    placement="right"
    :closable="false"
    @close="close"
    :visible="visible">
  
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">

        <a-form-item label="全库唯一码" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'puid', validatorRules.puid]" placeholder="请输入全库唯一码"></a-input>
        </a-form-item>
        <a-form-item label="采购方总部编码  国网:SGCC/南网：CSG/其他：QT" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'purchaserhqcode', validatorRules.purchaserhqcode]" placeholder="请输入采购方总部编码  国网:SGCC/南网：CSG/其他：QT"></a-input>
        </a-form-item>
        <a-form-item label="侧供应商编码" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'suppliercode', validatorRules.suppliercode]" placeholder="请输入侧供应商编码"></a-input>
        </a-form-item>
        <a-form-item label="供应商名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'suppliername', validatorRules.suppliername]" placeholder="请输入供应商名称"></a-input>
        </a-form-item>
        <a-form-item label="供应商工单编号" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'supplierworkno', validatorRules.supplierworkno]" placeholder="请输入供应商工单编号"></a-input>
        </a-form-item>
        <a-form-item label="采集规范版本号 默认为1" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'standardversion', validatorRules.standardversion]" placeholder="请输入采集规范版本号 默认为1"></a-input>
        </a-form-item>
        <a-form-item label="规格型号编码   默认，组合电器：gis596267/断路器：breaker478920" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'modelcode', validatorRules.modelcode]" placeholder="请输入规格型号编码   默认，组合电器：gis596267/断路器：breaker478920"></a-input>
        </a-form-item>
        <a-form-item label="物资品类类型       组合电器：40001/断路器：40002/隔离开关：40011" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'categorytype', validatorRules.categorytype]" placeholder="请输入物资品类类型       组合电器：40001/断路器：40002/隔离开关：40011"></a-input>
        </a-form-item>
        <a-form-item label="厂区编号" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'factorycode', validatorRules.factorycode]" placeholder="请输入厂区编号"></a-input>
        </a-form-item>
        <a-form-item label="供应商数据编号" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'suppliersupportid', validatorRules.suppliersupportid]" placeholder="请输入供应商数据编号"></a-input>
        </a-form-item>
        <a-form-item label="供应商产品厂内编码" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'productmodel', validatorRules.productmodel]" placeholder="请输入供应商产品厂内编码"></a-input>
        </a-form-item>
        <a-form-item label="生产设备名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'equipmentname', validatorRules.equipmentname]" placeholder="请输入生产设备名称"></a-input>
        </a-form-item>
        <a-form-item label="生产设备唯一标识号" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'equipmentuniquecode', validatorRules.equipmentuniquecode]" placeholder="请输入生产设备唯一标识号"></a-input>
        </a-form-item>
        <a-form-item label="感知过程" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'processtype', validatorRules.processtype]" placeholder="请输入感知过程"></a-input>
        </a-form-item>
        <a-form-item label="速度（副闸）  单位是m/s，副闸或叫分闸2，属于分闸" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input-number v-decorator="[ 'speeddeputy', validatorRules.speeddeputy]" placeholder="请输入速度（副闸）  单位是m/s，副闸或叫分闸2，属于分闸" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="速度（合闸）单位是m/s，合闸" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input-number v-decorator="[ 'speedclose', validatorRules.speedclose]" placeholder="请输入速度（合闸）单位是m/s，合闸" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="主闸  单位是m/s，副闸或叫分闸2，属于分闸" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input-number v-decorator="[ 'speedmain', validatorRules.speedmain]" placeholder="请输入主闸  单位是m/s，副闸或叫分闸2，属于分闸" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="时间（主闸）_A  单位是ms，主闸或叫分闸1，属于分闸" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input-number v-decorator="[ 'masteropentimea', validatorRules.masteropentimea]" placeholder="请输入时间（主闸）_A  单位是ms，主闸或叫分闸1，属于分闸" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="时间（主闸）_B  单位是ms，主闸或叫分闸1，属于分闸" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input-number v-decorator="[ 'masteropentimeb', validatorRules.masteropentimeb]" placeholder="请输入时间（主闸）_B  单位是ms，主闸或叫分闸1，属于分闸" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="时间（主闸）_C 单位是ms，主闸或叫分闸1，属于分闸" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input-number v-decorator="[ 'masteropentimec', validatorRules.masteropentimec]" placeholder="请输入时间（主闸）_C 单位是ms，主闸或叫分闸1，属于分闸" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="时间（副闸）_A  单位是ms，主闸或叫分闸1，属于分闸" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input-number v-decorator="[ 'salveopentimea', validatorRules.salveopentimea]" placeholder="请输入时间（副闸）_A  单位是ms，主闸或叫分闸1，属于分闸" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="时间（副闸）_B  单位是ms，主闸或叫分闸1，属于分闸" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input-number v-decorator="[ 'salveopentimeb', validatorRules.salveopentimeb]" placeholder="请输入时间（副闸）_B  单位是ms，主闸或叫分闸1，属于分闸" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="时间（副闸）_C  单位是ms，主闸或叫分闸1，属于分闸" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input-number v-decorator="[ 'salveopentimec', validatorRules.salveopentimec]" placeholder="请输入时间（副闸）_C  单位是ms，主闸或叫分闸1，属于分闸" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="时间（合闸）_A  单位是ms ，合闸" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input-number v-decorator="[ 'clonetimea', validatorRules.clonetimea]" placeholder="请输入时间（合闸）_A  单位是ms ，合闸" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="时间（合闸）_B  单位是ms ，合闸" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input-number v-decorator="[ 'clonetimeb', validatorRules.clonetimeb]" placeholder="请输入时间（合闸）_B  单位是ms ，合闸" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="时间（合闸）_C  单位是ms ，合闸" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input-number v-decorator="[ 'clonetimec', validatorRules.clonetimec]" placeholder="请输入时间（合闸）_C  单位是ms ，合闸" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="行程 单位 mm" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input-number v-decorator="[ 'route', validatorRules.route]" placeholder="请输入行程 单位 mm" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="行程图片_A文件名" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'routepicturea', validatorRules.routepicturea]" placeholder="请输入行程图片_A文件名"></a-input>
        </a-form-item>
        <a-form-item label="行程图片对象 对应的largeobject 对象的loid" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'routepictureaobj', validatorRules.routepictureaobj]" placeholder="请输入行程图片对象 对应的largeobject 对象的loid"></a-input>
        </a-form-item>
        <a-form-item label="行程图片_B文件名" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'routepictureb', validatorRules.routepictureb]" placeholder="请输入行程图片_B文件名"></a-input>
        </a-form-item>
        <a-form-item label="行程图片对象 对应的largeobject 对象的loid" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'routepicturebobj', validatorRules.routepicturebobj]" placeholder="请输入行程图片对象 对应的largeobject 对象的loid"></a-input>
        </a-form-item>
        <a-form-item label="行程图片_C文件名" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'routepicturec', validatorRules.routepicturec]" placeholder="请输入行程图片_C文件名"></a-input>
        </a-form-item>
        <a-form-item label="行程图片对象 对应的largeobject 对象的loid" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'routepicturecobj', validatorRules.routepicturecobj]" placeholder="请输入行程图片对象 对应的largeobject 对象的loid"></a-input>
        </a-form-item>
        <a-form-item label="波形数据" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'waveform', validatorRules.waveform]" placeholder="请输入波形数据"></a-input>
        </a-form-item>
        <a-form-item label="采集时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-date placeholder="请选择采集时间" v-decorator="[ 'checktime', validatorRules.checktime]" :trigger-change="true" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="工序编码" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'pdcode', validatorRules.pdcode]" placeholder="请输入工序编码"></a-input>
        </a-form-item>
        <a-form-item label="状态表示 默认为1" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'ioflag', validatorRules.ioflag]" placeholder="请输入状态表示 默认为1"></a-input>
        </a-form-item>
        <a-form-item label="接口返回同步错误信息" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'message', validatorRules.message]" placeholder="请输入接口返回同步错误信息"></a-input>
        </a-form-item>
        <a-form-item label="预留字段1" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'remark1', validatorRules.remark1]" placeholder="请输入预留字段1"></a-input>
        </a-form-item>
        <a-form-item label="预留字段2" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'remark2', validatorRules.remark2]" placeholder="请输入预留字段2"></a-input>
        </a-form-item>
        <a-form-item label="预留字段3" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'remark3', validatorRules.remark3]" placeholder="请输入预留字段3"></a-input>
        </a-form-item>
        <a-form-item label="预留字段4" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'remark4', validatorRules.remark4]" placeholder="请输入预留字段4"></a-input>
        </a-form-item>
        <a-form-item label="预留字段5" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'remark5', validatorRules.remark5]" placeholder="请输入预留字段5"></a-input>
        </a-form-item>
        
      </a-form>
    </a-spin>
    <a-button type="primary" @click="handleOk">确定</a-button>
    <a-button type="primary" @click="handleCancel">取消</a-button>
  </a-drawer>
</template>

<script>

  import { httpAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import JDate from '@/components/jeecg/JDate'  
  
  export default {
    name: "EipMechanicalCharacteristicsModal",
    components: { 
      JDate,
    },
    data () {
      return {
        form: this.$form.createForm(this),
        title:"操作",
        width:800,
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },

        confirmLoading: false,
        validatorRules:{
        puid:{rules: [{ required: true, message: '请输入全库唯一码!' }]},
        purchaserhqcode:{},
        suppliercode:{},
        suppliername:{},
        supplierworkno:{},
        standardversion:{},
        modelcode:{},
        categorytype:{},
        factorycode:{},
        suppliersupportid:{},
        productmodel:{},
        equipmentname:{},
        equipmentuniquecode:{},
        processtype:{},
        speeddeputy:{},
        speedclose:{},
        speedmain:{},
        masteropentimea:{},
        masteropentimeb:{},
        masteropentimec:{},
        salveopentimea:{},
        salveopentimeb:{},
        salveopentimec:{},
        clonetimea:{},
        clonetimeb:{},
        clonetimec:{},
        route:{},
        routepicturea:{},
        routepictureaobj:{},
        routepictureb:{},
        routepicturebobj:{},
        routepicturec:{},
        routepicturecobj:{},
        waveform:{},
        checktime:{},
        pdcode:{},
        ioflag:{},
        message:{},
        remark1:{},
        remark2:{},
        remark3:{},
        remark4:{},
        remark5:{},
        },
        url: {
          add: "/pg/eipMechanicalCharacteristics/add",
          edit: "/pg/eipMechanicalCharacteristics/edit",
        }
     
      }
    },
    created () {
    },
    methods: {
      add () {
        this.edit({});
      },
      edit (record) {
        this.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model,'puid','purchaserhqcode','suppliercode','suppliername','supplierworkno','standardversion','modelcode','categorytype','factorycode','suppliersupportid','productmodel','equipmentname','equipmentuniquecode','processtype','speeddeputy','speedclose','speedmain','masteropentimea','masteropentimeb','masteropentimec','salveopentimea','salveopentimeb','salveopentimec','clonetimea','clonetimeb','clonetimec','route','routepicturea','routepictureaobj','routepictureb','routepicturebobj','routepicturec','routepicturecobj','waveform','checktime','pdcode','ioflag','message','remark1','remark2','remark3','remark4','remark5'))
        })
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        const that = this;
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            let formData = Object.assign(this.model, values);
            console.log("表单提交数据",formData)
            httpAction(httpurl,formData,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }
         
        })
      },
      handleCancel () {
        this.close()
      },
      popupCallback(row){
        this.form.setFieldsValue(pick(row,'puid','purchaserhqcode','suppliercode','suppliername','supplierworkno','standardversion','modelcode','categorytype','factorycode','suppliersupportid','productmodel','equipmentname','equipmentuniquecode','processtype','speeddeputy','speedclose','speedmain','masteropentimea','masteropentimeb','masteropentimec','salveopentimea','salveopentimeb','salveopentimec','clonetimea','clonetimeb','clonetimec','route','routepicturea','routepictureaobj','routepictureb','routepicturebobj','routepicturec','routepicturecobj','waveform','checktime','pdcode','ioflag','message','remark1','remark2','remark3','remark4','remark5'))
      }
      
    }
  }
</script>

<style lang="less" scoped>
/** Button按钮间距 */
  .ant-btn {
    margin-left: 30px;
    margin-bottom: 30px;
    float: right;
  }
</style>